/*******************************************************************************
 * This file is part of blueprint4j www.blueprint4j.org.
 * 
 *     blueprint4j is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU Lesser General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 * 
 *     blueprint4j is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU Lesser General Public License for more details.
 * 
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with blueprint4j. If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
/**
* This is an abstract message class no fields have been defined in this
* class
* $Log: MessageISOField8583Postilion.java,v $
* Revision 1.1.1.1  2004/04/22 12:56:14  travisb
* Fir
*
* Revision 1.1.1.1  2003/12/21 09:04:08  jaspervdb
* no message
*
* Revision 1.1.1.1  2003/10/20 15:30:48  travisb
* First import into CVS at Cellstop
*
* Revision 1.1.1.1  2003/03/30 15:25:28  tbulford
* no message
*
* Revision 1.1  2003/01/12 08:30:34  travis
* Import x MANY
*
* Revision 1.1.1.1  2002/12/16 22:14:01  jasper
* no message
*
* Revision 1.4  2002/04/22 09:03:37  travisb
* Before Backup
*
* Revision 1.3  2002/03/08 15:06:42  travisb
* Tunnel added
*
* Revision 1.2  2002/03/07 11:23:51  travisb
* Small formatting changes
*
* Revision 1.1  2002/02/20 13:30:43  JasperV
* First time add to new Applications layer
*
* Revision 1.1  2002/01/24 14:18:14  travisb
* First Version of the Application Layer
*
*/

package blueprint4j.messages;

import java.io.*;
import java.util.*;
import java.text.*;

public class MessageISOField8583Postilion extends MessageISOField8583 {
	PostilionField postilion_field = null;

	public MessageISOField8583Postilion()
	throws ExceptionMessage {
		super();
		postilion_field = new PostilionField();
		fields[127] = new FieldMessage(Field.LENGTH_LLLLLLVAR, 999999, 127, "Postilion Private Field", postilion_field);
	}

	public void setPostilionField(int field, String value)
	throws ExceptionMessage {
		postilion_field.set(field, value);
	}

	/**
	* Returns all the message details in properties string adds the fields values for the extended fields in 2
	* <code><br>
	* Type=0100 <br>
	* Field_3=220000 <br>
	* Field_4=2900 <br>
	* Field_7=0921182451 <br>
	* Field_127.6=1232535243 <br>
	* </code>
	*/
	public String getMessageAsString()
	throws ExceptionMessage {
		String value = super.getMessageAsString();
		// Set fields from properties
		for (int t = 2;t < 128;t++) {
			if (postilion_field.hasField(t)) {
				String f = getPostilionField(t);
				if (f != null) {
					value += "Field_127." + t + "=" + f + "\n";
				}
			}
		}
		// Return the properties
		return value;
	}

	public String getPostilionField( int field_no )
	throws ExceptionMessage {
		return postilion_field.get(field_no);
	}

	class PostilionField extends MessageISOField {
		PostilionField() throws ExceptionMessage {
			message_type = null;
			fields[0] = new FieldB(Field.LENGTH_FIXED, 8, 0, "Bit Map");
			fields[1] = new FieldB(Field.LENGTH_FIXED, 8, 1, "Bit Map Extended");
			fields[2] = new FieldANS(Field.LENGTH_LLVAR, 32, 2, "Field 127.2 - Switch Key");
			fields[3] = new FieldANS(Field.LENGTH_FIXED, 48, 3, "Field 127.3 - Routing Information");
			fields[4] = new FieldANS(Field.LENGTH_FIXED, 22, 4, "Field 127.4 - POS Data");
			fields[5] = new FieldANS(Field.LENGTH_FIXED, 73, 5, "Field 127.5 - Service Station Data");
			fields[6] = new FieldN(Field.LENGTH_FIXED, 2, 6, "Field 127.6 - Authorization Profile");
			fields[7] = new FieldANS(Field.LENGTH_LLVAR, 50, 7, "Field 127.7 - Check Data");
			fields[8] = new FieldANS(Field.LENGTH_LLLVAR, 999, 8, "Field 127.8 - Retention Data");
			fields[9] = new FieldANS(Field.LENGTH_LLLVAR, 999, 9, "Field 127.9 - Additional Node Data");
			fields[10] = new FieldN(Field.LENGTH_FIXED, 3, 10, "Field 127.10 - CVV2");
			fields[11] = new FieldANS(Field.LENGTH_LLVAR, 32, 11, "Field 127.11 - Original Key");
			fields[12] = new FieldANS(Field.LENGTH_LLVAR, 25, 12, "Field 127.12 - Terminal Owner");
			fields[13] = new FieldANS(Field.LENGTH_FIXED, 17, 13, "Field 127.13 - POS Geographic Data");
			fields[14] = new FieldANS(Field.LENGTH_FIXED, 8, 14, "Field 127.14 - Sponsor Bank");
			fields[15] = new FieldANS(Field.LENGTH_LLVAR, 29, 15, "Field 127.15 - Address Verification Data");
			fields[16] = new FieldANS(Field.LENGTH_FIXED, 1, 16, "Field 127.16 - Address Verification Result");
			fields[17] = new FieldANS(Field.LENGTH_LLVAR, 50, 17, "Field 127.17 - Cardholder Information");
			fields[18] = new FieldANS(Field.LENGTH_LLVAR, 50, 18, "Field 127.18 - Validation data");
			fields[19] = new FieldANS(Field.LENGTH_LLVAR, 31, 19, "Field 127.19 - Bank details");
			fields[20] = new FieldN(Field.LENGTH_FIXED, 8, 20, "Field 127.20 - Authorizer date settlement");
			fields[21] = new FieldANS(Field.LENGTH_LLVAR, 12, 21, "Field 127.21 - Record identification");
			fields[22] = new FieldANS(Field.LENGTH_LLLLLVAR, 99999, 22, "Field 127.22 - Structured data");
			fields[23] = new FieldANS(Field.LENGTH_FIXED, 253, 23, "Field 127.23 - Payee name and address");
			fields[24] = new FieldANS(Field.LENGTH_LLLLVAR, 9999, 24, "Field 127.25 - Integrated circuit card (ICC) data");
		}
	}
}

